home *** CD-ROM | disk | FTP | other *** search
/ 220 Jogos / 220 jogos.iso / tetris / tetron / SOURCE / GAMEMAIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-13  |  3.5 KB  |  107 lines

  1. //----------------------------------------------------------------------------------------
  2. //----------------------------------------------------------------------------------------
  3. //
  4. //        Filename        :    gamemain.h
  5. //        Description        :    Header file for GameMain class
  6. //        Author            :   Marnich van Rensburg (2002)
  7. //
  8. //----------------------------------------------------------------------------------------
  9. //----------------------------------------------------------------------------------------
  10.  
  11. #include <windows.h>
  12. #include <time.h>        // For time()
  13. #include <stdlib.h>        // For srand() and rand()
  14. #include "opengl.h"
  15. #include "tetramino.h"
  16. #include "container.h"
  17. #include "top10.h"
  18.  
  19. //----------------------------------------------------------------------------------------
  20. //        External Globals
  21. //----------------------------------------------------------------------------------------
  22.  
  23. extern bool SoundActive;
  24. extern bool StarFieldActive;
  25.  
  26.  
  27. //----------------------------------------------------------------------------------------
  28. //        Constants
  29. //----------------------------------------------------------------------------------------
  30.  
  31. #ifndef GAMEMAIN_H
  32. #define GAMEMAIN_H
  33.  
  34.  
  35. #define GAME_NAME Tetron
  36.  
  37. //Player Actions
  38. #define PLR_MOVE_RIGHT        VK_RIGHT
  39. #define PLR_MOVE_LEFT        VK_LEFT
  40. #define PLR_MOVE_DOWN        VK_DOWN
  41. #define PLR_MOVE_DROP        45
  42. #define PLR_ROTATE_LEFT        190
  43. #define PLR_ROTATE_RIGHT    188
  44.  
  45.  
  46. //Scoring Defaults
  47. #define SCR_TETRAMINO_DROPPED        4
  48. #define SCR_ONE_LINE_REMOVED        10
  49. #define SCR_TWO_LINES_REMOVED        25
  50. #define SCR_THREE_LINES_REMOVED        75
  51. #define SCR_FOUR_LINES_REMOVED        300
  52.  
  53. //Game Modes
  54. #define GAME_START_SCREEN    1
  55. #define GAME_ACTIVE            2
  56. #define GAME_NEW_HIGHSCORE    3
  57.  
  58.  
  59.  
  60. //----------------------------------------------------------------------------------------
  61. //    Class Definition for GameMain Class
  62. //----------------------------------------------------------------------------------------
  63.  
  64. class GameMain
  65. {
  66.     //---------------------- Public -------------------------
  67.  
  68.     public:
  69.         
  70.         // Member Functions
  71.         int Mode;                // Current state of game
  72.         GameMain();                // Constructor
  73.         bool GameOver;
  74.         bool Init();            // Prepares for running the game returns false if failed
  75.         void New();                // Reset the game
  76.         void StartScreen(unsigned char UserAction);        // Displays main startup screen
  77.         void Play(unsigned char UserAction);    // Initiates gameplay sequence ie. the Gameloop
  78.         void GetHighScore(unsigned char UserAction);
  79.         void Quit();            // Shutdown
  80.  
  81.     //---------------------- Private -------------------------
  82.  
  83.     private:
  84.         
  85.         //Data Members
  86.         OpenGL GameGL;            // OpenGL Object For Graphics
  87.         Container ConCurrent;    // Container Object
  88.         Tetramino TetCurrent;    // Tetramino currently in play
  89.         Tetramino TetNext;        // Tetramino to be used next
  90.         GameStats Stats;        // Holds all game statistics ie. score etc.
  91.         Top10 HighScores;        // Table of top ten highscores
  92.         unsigned int Speed;        // Tetranimo falling speed
  93.         bool Drop;                // true while tetranimo is being droped
  94.         char DropHeight;        // The hight from wich the tetramino was dropped used in scoring
  95.         char DropStarty;
  96.  
  97.         // Member Functions
  98.         char Random();            // For generating random tetraminos
  99.         void Render();            // Render the game onto the screen
  100.         void SetScore(char NoOfLines);    // Calculates new score
  101.         void StartNext();        // Sets NEXT piece to CURRENT and inits another NEXT piece
  102.  
  103.         bool ValidInput(unsigned char Val);    // verifies user text input
  104.  
  105. };//Class GameMain
  106.  
  107. #endif;